﻿CREATE VIEW [dbo].[ASMS_V_Warehouse]
	AS
SELECT 
	W.* ,
	MDICountry.Name as CountryName,
	MDIProvince.Name as ProvinceName,
	MDICity.Name as CityName,
	MDIDistrict.Name as DistrictName,
	S.Name as StationName,
	B.Name as BusinessName
FROM ASMS_Warehouse as W
	left join [ASMS_Station] as S on S.Id = W.StationId
	left join ASMS_Business as B on B.Id = W.BusinessId
	left join [ASMS_MasterDataItem] as MDICountry on MDICountry.Code = W.Country
	left join [ASMS_MasterDataItem] as MDIProvince on MDIProvince.Code = W.Province
	left join [ASMS_MasterDataItem] as MDICity on MDICity.Code = W.City
	left join [ASMS_MasterDataItem] as MDIDistrict on MDIDistrict.Code = W.District